import { FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';

export const formSchema: FormSchema[] = [
  {
    field: 'code',
    component: 'Input',
    label: '应用编码',
    rules: [
      { required: true, message: '请输入应用编码!' },
      { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
    ],
  },
  {
    field: 'name',
    component: 'Input',
    label: '应用名称',
    rules: [
      { required: true, message: '请输入应用名称!' },
      { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
    ],
  },
  {
    field: 'icon',
    label: '图标',
    component: 'JImageUpload',
  },
  {
    field: 'description',
    component: 'InputTextArea',
    label: '描述',
    rules: [{ min: 0, max: 126, message: '长度不超过 126 个字符', trigger: 'blur' }],
  },
];

export const applicationMenuFormSchema: FormSchema[] = [
  {
    field: 'code',
    component: 'Input',
    label: '菜单编码',
    rules: [{ required: true, message: '请输入菜单编号', trigger: 'blur' }],
  },
  {
    field: 'name',
    component: 'Input',
    label: '菜单名称',
    rules: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
  },
  {
    field: 'parentId',
    label: '上级节点',
    component: 'TreeSelect',
    required: true,
  },
  {
    field: 'icon',
    component: 'IconPicker',
    label: '菜单图标',
  },
  {
    field: 'routeUrl',
    component: 'Input',
    label: '路由规则',
    required: true,
  },
  {
    field: 'url',
    component: 'Input',
    label: '路由地址',
  },
  {
    field: 'component',
    component: 'Input',
    label: '组件路径',
    rules: [{ required: true, message: '请输入前端组件路径', trigger: 'blur' }],
  },
  {
    field: 'sort',
    component: 'InputNumber',
    label: '排序',
  },
  {
    field: 'alwaysShow',
    component: 'Switch',
    label: '聚合子路由',
  },
  {
    field: 'route',
    component: 'Switch',
    label: '路由菜单',
  },
  {
    field: 'hidden',
    component: 'Switch',
    label: '隐藏资源',
  },
  {
    field: 'keepAlive',
    component: 'Switch',
    label: '缓存资源',
  },
  {
    field: 'leaf',
    component: 'Switch',
    label: '叶子节点',
  },
  {
    field: 'managerMenu',
    component: 'Switch',
    label: '管理员资源',
  },
  {
    field: 'description',
    component: 'InputTextArea',
    label: '描述',
  },
];

export const applicationOperationColumns: BasicColumn[] = [
  { title: '编码', align: 'center', dataIndex: 'code' },
  { title: '名称', align: 'center', dataIndex: 'name' },
  { title: '状态', align: 'center', dataIndex: 'requiredStatus' },
  { title: '创建时间', align: 'center', dataIndex: 'createTime' },
];

export const applicationOperationFormSchema: FormSchema[] = [
  {
    field: 'code',
    component: 'Input',
    label: '操作编码',
    required: true,
  },
  {
    field: 'name',
    component: 'Input',
    label: '操作名称',
    required: true,
  },
  {
    field: 'requiredStatus',
    label: '状态',
    component: 'Select',
    required: true,
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 2 },
      ],
    },
  },
];
